package com.heixiu.gallery2

import android.content.Context
import com.android.volley.RequestQueue
import com.android.volley.toolbox.Volley

class VolleySingleton private constructor(context: Context) {
    companion object { // 静态作用域，里面得是静态属性和方法
        private var instance: VolleySingleton? = null
        fun getInstance(context: Context) =
            instance ?: VolleySingleton(context).also { instance = it }

    }

    // by lazy和等号得作用一样是赋值，但 by lazy 是用到才会赋值
    val requestQueue: RequestQueue by lazy {
        Volley.newRequestQueue(context.applicationContext)
    }
}